def merge(listLeft, listRight):
    left, right = 0 ,0
    leftLen, rightLen = len(listLeft), len(listRight)
    nums = []
    while left < leftLen and right < rightLen:
        print(listLeft)
        print(listRight)
        if listLeft[left] <= listRight[right]:
            nums.append(listLeft[left])
            left += 1
        else:
            nums.append(listRight[right])
            right += 1
    nums += listLeft[left:]
    nums += listRight[right:]
    return nums

def mergeSort(myList):
    n = len(myList)
    if n <= 1:
        return myList

    mid = n // 2
    leftList = mergeSort(myList[:mid])
    rightList = mergeSort(myList[mid:])
    return merge(leftList, rightList)


if __name__ == "__main__":
    myList = [12, 33, 199, 0, 54, 33, 11, 12]
    result = mergeSort(myList)
    print(f'归并排序后：{result}')
